# 12. 找座位
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.on('line', (input) => {
let max = 0;
for(let i=0; i<input.length; i++) {
if (input[i] === '0' && (i === 0 || input[i-1] === '0') && (i === input.length - 1 || input[i+1] === '0')) {
max++;
input = input.substr(0, i) + '1' + input.substr(i + 1);
i++;
}
}
console.log(max);
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
← 11. 环中最长子串 13. 转盘寿司 →